Crate nakamoto_p2p[−][src]
Nakamoto's peer-to-peer library.
The p2p
crate implements the core protocol state-machine. It can be found under the
protocol module, which has the following sub-protocol:
AddressManager
: handles peer address exchangeSyncManager
: handles block header syncConnectionManager
: handles peer connectionsPingManager
: handles pings and pongsSpvManager
: handles compact filter syncPeerManager
: handles peer handshake
Nakamoto's implementation of the peer-to-peer protocol(s) is I/O-free. The core logic is implemented as a state machine with inputs and outputs and a step function that does not perform any network I/O.
The reason for this is to keep the protocol code easy to read and simple to test. Not having I/O minimizes the possible error states and error-handling code in the protocol, and allows for a fully deterministic protocol. This means failing tests can always be reproduced and 100% test coverage is within reach.
To achieve this, handling of network I/O is cleanly separated into a network
reactor. See the nakamoto-net-poll
crate for an example of a reactor.
Re-exports
pub use bitcoin; |
pub use protocol::PeerId; |
Modules
error | Peer-to-peer protocol errors. |
event | Events generated by the peer-to-peer system. |
protocol | Bitcoin protocol state machine. |
reactor | Reactor trait. |